import 'package:enterprise_v6_app/app/components/custom_modele/custom_row_title.dart';
import 'package:enterprise_v6_app/app/components/custom_modele/custom_title_content_view.dart';
import 'package:enterprise_v6_app/app/components/custom_refresh.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';
import 'package:enterprise_v6_app/router/app_pages.dart';

/// 出入记录-详情
class AssessRecord extends StatefulWidget {
  const AssessRecord({ super.key});

  @override
  State<AssessRecord> createState() => _AssessRecordState();
}

class _AssessRecordState extends State<AssessRecord> {
  // 报警状态
  Widget _status(int i) {
    if (i == 0) {
      return Container(
        padding: EdgeInsets.symmetric(vertical: 2.w, horizontal: 8.w),
        decoration: BoxDecoration(
            color: const Color(0xFF5C6DFF),
            borderRadius: BorderRadius.only(
              topLeft: Radius.circular(8.r),
              bottomRight: Radius.circular(8.r),
              topRight: Radius.circular(8.r),
            )),
        child: Text('正常',
            style: TextStyle(
              fontSize: 10.sp,
              color: Colors.white,
            )),
      );
    }
    return Container(
      padding: EdgeInsets.symmetric(vertical: 2.w, horizontal: 8.w),
      decoration: BoxDecoration(
          color: const Color(0xFFFD6B6B),
          borderRadius: BorderRadius.only(
            topLeft: Radius.circular(8.r),
            bottomRight: Radius.circular(8.r),
            topRight: Radius.circular(8.r),
          )),
      child: Text('报警($i)',
          style: TextStyle(
            fontSize: 10.sp,
            color: Colors.white,
          )),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(
        left: AppDimens.dp16,
        right: AppDimens.dp16,
        top: AppDimens.dp16,
      ),
      child: CustomEasyRefreshList(
        dataLoad: (pageNum, pageSize, {search}) async {
          return [
            '1',
            '2',
          ];
        },
        itemBuilder: (item, index) {
          return CustomTitleContentView(
            title: Row(
              children: [
                SvgPicture.asset(
                  AppImages.icon_title,
                  width: 20.w,
                  height: 20.w,
                ),
                AppGaps.hGap6,
                Text(
                  '姓名${index + 1}',
                  style: TextStyle(color: const Color(0xff333333), height: 1.2, fontWeight: FontWeight.w500, fontSize: 15.sp),
                ),
                const Spacer(),
                _status(index),
              ],
            ),
            content: Column(
              children: [
                AppGaps.vGap6,
                Container(
                  width: double.infinity,
                  padding: EdgeInsets.only(left: 12.w, right: 12.w, top: 6.w, bottom: 6.w),
                  decoration: BoxDecoration(
                    color: const Color(0xFFF7F7FB),
                    borderRadius: BorderRadius.circular(4.w),
                  ),
                  child: Text(
                    '2023-02-12 12:00 至 2023-12-12 14:00',
                    style: TextStyle(
                      color: const Color(0xFF5C6DFF),
                      fontSize: 14.sp,
                    ),
                  ),
                ),
                const CustomRowTitle(
                  title: '联系电话',
                  content: '17623768956',
                ),
                const CustomRowTitle(
                  title: '来访事由',
                  content: '来访事由',
                ),
              ],
            ),
          ).click(() {
            Get.toNamed(AppRoutes.accessRecordDetailsPersonnelList);
          });
        },
      ),
    );
  }
}
